//
//  KYCommon.h
//  KYKJPackDemo
//
//  Created by Jordan zhou on 2017/9/21.
//  Copyright © 2017年 ???. All rights reserved.
//

#ifndef KYCommon_h
#define KYCommon_h

// 自定义日志打印
#ifdef DEBUG
#define KYLog(...) NSLog(@"%s\n %@ \n\n",__func__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define KYLog(...)
#endif

// 判断是否为iOS7
#define iOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)

/**---- 导航栏 ---- */
// 获得RGB颜色
#define KYColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/1.0]
// 导航栏标题颜色
#define KYNavigationBarTitleColor KYColor(65, 65, 65, 1)
// 导航栏标题字体
#define KYNavigationBarTitleFont [UIFont boldSystemFontOfSize:17.5f]
// 导航栏按钮文字字体
#define KYBarButtonTitleFont [UIFont boldSystemFontOfSize:16.5]
// 导航栏按钮文字颜色
#define KYBarButtonTitleColor (iOS7 ? KYColor(239, 113, 0, 1) : KYColor(119, 119, 119, 1))
#define KYBarButtonTitleDisabledColor KYColor(208, 208, 208, 1)

// 数据存储
#define KYUserDefaults [NSUserDefaults standardUserDefaults]

// 通知中心对象
#define KYNotificationCenter [NSNotificationCenter defaultCenter]

// 定义屏幕尺寸适配修改
#define kScreenWidth    [UIScreen mainScreen].bounds.size.width
#define kScreenHeight   [UIScreen mainScreen].bounds.size.height
#define kMainWindow     [UIApplication sharedApplication].keyWindow
#define kAppDelegate    ((AppDelegate *)[UIApplication sharedApplication].delegate)

// 当前屏幕size
#define kDefaultSize                         CGSizeMake(kDeviceWidth, kDeviceHeight)
// 当前屏幕适配宽度（以 iPhone5、iPhone5s为标准）
#define kCurrentScreenWidth(x)               ([UIScreen mainScreen].bounds.size.width/320.)*x
#define kCurrentScreenHeight(x)              ([UIScreen mainScreen].bounds.size.height/568.)*x
// 新增当前屏幕适配宽度（以 iPhone6、iPhone6s为标准）
#define kRealScreenWidth(x)               ([UIScreen mainScreen].bounds.size.width/375.)*x
#define kRealScreenHeight(x)              ([UIScreen mainScreen].bounds.size.height/667.)*x
// 横屏模式
#define kRealLandscapeScreenWidth(x)               ([UIScreen mainScreen].bounds.size.width/667.)*x
#define kRealLandscapeScreenHeight(x)              ([UIScreen mainScreen].bounds.size.height/375.)*x

// 是否为nil或是NSNull对象
#define NotNilAndNull(_ref)  (((_ref) != nil) && (![(_ref) isEqual:[NSNull null]]) && (![(_ref) isEqual:@"null"]) && (![(_ref) isEqual:@"(null)"]))

#define IsNilOrNull(_ref)   (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref) isEqual:@"null"]) || ([(_ref) isEqual:@"(null)"]))

// 字符串是否为空
#define IsStrEmpty(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([(_ref)isEqualToString:@""]) || ([(_ref)isEqualToString:@"(null)"]))

// 数组是否为空
#define IsArrEmpty(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([(_ref) count] == 0))

// 接口请求类型
#define AFRequestMethodPost @"POST"
#define AFRequestMethodGet @"GET"

// 字体设置
#define kSystemFont(size) [UIFont systemFontOfSize:size]
#define kBoldSystemFont(size) [UIFont boldSystemFontOfSize:size]

// 设备类型判断
#define isIPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIPhone6p ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIPhone6s ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIPhone7 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIPhone7p ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

// 系统版本判断
#define IOS10_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"10.0"] != NSOrderedAscending)
#define IOS9_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"9.0"] != NSOrderedAscending )
#define IOS8_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"8.0"] != NSOrderedAscending )
#define IOS7_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )
#define IOS6_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"6.0"] != NSOrderedAscending )
#define IOS5_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"5.0"] != NSOrderedAscending )
#define IOS4_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"4.0"] != NSOrderedAscending )
#define IOS3_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"3.0"] != NSOrderedAscending )
#define IS_IPAD         (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)

#define IOS_SYSTEM_VERSION      [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion    [[UIDevice currentDevice] systemVersion]

// 字体类型
#define HeitiBold                   @"STHeitiSC-Medium"
#define Heiti                       @"STHeitiSC-Light"
#define HeitiTC                     @"STHeitiTC-Light"
#define HelBold                     @"Helvetica-Bold"
#define Hel                         @"Helvetica"
#define HelNeue                     @"HelveticaNeue-Light"

#warning - NO(确定后删除的)
#define kOnClick @"onClick"
#define kRemoveView @"removeView"
#define CacheTimeInterval 0 //设置统计间隔8小时
#define kFilteredDic              [JSTSystemInfo advertFilteredDic]
#define kFilteredId               [JSTSystemInfo advertFilteredIdData]
#define kFilteredStr              [JSTSystemInfo advertFilteredStrData]
#define kUaDic                    [JSTHttpClient uaDic]
#define kPostAdvertDic            [JSTHttpClient postAdvertDataDic]
#define kHomePageModel            [JSTSystemInfo currentModel]
#define kStr(obj)                 [JSTSystemInfo getStr:obj]
#define kPublicModel                      [PublicModel sharePublicModel]
#define kPublicReadCtl                    [PublicModel shareReadCtl]
#define kPublicHomePage                   [PublicModel shareHomePageCtl]
#define kAbc(x)                   20*x
#define kIsAgree                  [JSTSystemInfo isAgree]
#define kIsReadLoad               [AppDelegate currentAppDelegate].isReadLoad
#define GDIPA_KEY                 @"8d0c27eee648108f745cb413547aa86a"
#define HomePage                  [JSTWebHomePageViewController shareHomePageCtl]
#define kAdvertKP                           @"kp"
#define kAdvertHP                           @"hp"
#define FirstNum                            @"1"
#define TimeInterval                        24.*3600.
#define OtherTimeInterval                   0.5*3600.
#define kPv                                 @"view"
#define kClick                              @"click"
//导航栏高度
#define kNavBarHeight                        64.0
//状态栏高度
#define kBatteryCellHeight                   20
//tabbar高度
#define kTabbarHeight                        49
//当前屏幕frame
#define kDeviceFrame                         [[UIScreen mainScreen] bounds]
//当前屏幕出去状态栏高度
#define kNavViewHight                       ([UIScreen mainScreen].bounds.size.height-20)
//当前屏幕宽度
#define kDeviceWidth                        ([UIScreen mainScreen].bounds.size.width)
//当前屏幕总高度
#define kDeviceHeight                       ([UIScreen mainScreen].bounds.size.height)
#define kAutoDeviceWidth(kWidth)            (kWidth/320.0)*([UIScreen mainScreen].bounds.size.width)
#define WeakSelf __weak typeof(self) _self = self;
#define StrongSelf __strong typeof(_self) self = _self;

//颜色
#define kClearColor                         [UIColor clearColor]
#define kRedColor                           [UIColor redColor]
#define kWhiteColor                         [UIColor whiteColor]
#define kBlackColor                         [UIColor blackColor]
#define kSPBackgoundColor                   [UIColor colorWithHexString:@"eeeeee"]
#define kSPSeparateLineColor                [UIColor colorWithHexString:@"c8c8c8"]
#define kSPNavColor                         [UIColor colorWithHexString:@"fdfdfd"]
#define kSPRedColor                         [UIColor colorWithHexString:@"f12424"]
#define kSPGreenColor                       [UIColor colorWithHexString:@"3ac995"]
#define kSPBlueColor                        [UIColor colorWithHexString:@"40b7f7"]
#define kSPLightRedColor                    [UIColor colorWithHexString:@"ff5d5d"]
#define kSPYellowColor                      [UIColor colorWithHexString:@"ffbb33"]
#define kSPBlackTextColor                   [UIColor colorWithHexString:@"141414"]
#define kSPGrayTextColor                    [UIColor colorWithHexString:@"838383"]
#define kSPLightGrayTextColor               [UIColor colorWithHexString:@"c8c8c8"]

#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

//本地化转换
#undef L
#define L(key) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]

typedef void (^SNBasicBlock)(void);

//判断语音
/*SN_EXTERN*/
#if !defined(SN_EXTERN)
#  if defined(__cplusplus)
#   define SN_EXTERN extern "C"
#  else
#   define SN_EXTERN extern
#  endif
#endif

#define RGB(R, G, B)    [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0]
#define TopSpacing 40.0f
#define BottomSpacing 40.0f
#define LeftSpacing 20.0f
#define RightSpacing  20.0f
#define DELAYEXECUTE(delayTime,func) (dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{func;}))
#define DistanceFromTopGuiden(view) (view.frame.origin.y + view.frame.size.height)
#define DistanceFromLeftGuiden(view) (view.frame.origin.x + view.frame.size.width)
#define ViewOrigin(view)   (view.frame.origin)
#define ViewSize(view)  (view.frame.size)
#define ScreenSize [UIScreen mainScreen].bounds.size

#define LSYNoteNotification @"LSYNoteNotification"
#define LSYThemeNotification @"LSYThemeNotification"
#define LSYEditingNotification @"LSYEditingNotification"
#define LSYEndEditNotification @"LSYEndEditNotification"

#define MinFontSize 11.0f
#define MaxFontSize 20.0f

#warning - NO 新增
#define EvaluationCellInset 10
#define kNewCurrentScreen(x)                ([UIScreen mainScreen].bounds.size.width/375.)*x
#define kLoginLabelWidth                    kCurrentScreenWidth(60)
#define kANGSeparateLineColor               [UIColor colorWithHexString:@"e0e0e0"]
#define kWidthProportion                    (float)[UIScreen mainScreen].bounds.size.width/320.0
#define kANGNavColor                        [UIColor colorWithHexString:@"ff7800"]
#define kANGBrownColor                      [UIColor colorWithHexString:@"421408"]
#define kANGBackgoundColor                  [UIColor colorWithHexString:@"eeeeee"]
#define kANGColor                           [UIColor colorWithHexString:@"e48e1d"]

/** 微信key */
#define WeixinKey                               @"wxf5dfc3c57f40ee59"
/**  */
#define kWeChatCllback                          @"WeChatCallback"
#define kWeiXinRefreshToken                     @"WeiXinRefreshToken"
#define kWeiXinOpenId                           @"WeiXinOpenId"
#define kWeiXinAccessToken                      @"WeiXinAccessToken"
#define WeixinSecret                            @"d4624c36b6795d1d99dcf0547af5443d"
#define weixinPlatform                          @"Weixin"
#define qqPlatform                              @"qq"
#define qqAppId                                 @"1106409392"

#endif /* KYCommon_h */
